package com.yx.front.controller;

import com.yx.front.config.global.CommonResult;
import com.yx.front.model.SysUser;
import com.yx.front.security.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @author YangXiong
 */
@Slf4j
@RestController
@RequestMapping("/api")
@Api(tags = "注册登录控制器")
public class LoginController {
    @Resource
    private LoginService loginService;

    @PostMapping("/login")
    @ApiOperation("登录接口")
    public CommonResult<HashMap<String,String>> login(@RequestBody SysUser sysUser){
        log.info("LoginController info login SysUser={}", sysUser);
        return loginService.login(sysUser);
    }

    @GetMapping("/logout")
    @ApiOperation("登出接口")
    public CommonResult<String> logout(){
        log.info("===========>>>>>>logout");
        return loginService.logout();
    }
}
